home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / extmath.exe / EXTCMP.S < prev    next >
Text File  |  1993-01-05  |  1KB  |  58 lines

  1. ; Unsigned comparison of two 64-bit numbers
  2. ;   result preserves sign logic of ExtSub()
  3. ;
  4. ; Tim Victor, January 5, 1993
  5. ;
  6. ; Callable from C as follows:
  7. ; int ExtCmp(src, dest);
  8. ;
  9. ;   returns:
  10. ;      1 if dest > src
  11. ;      0 if dest = src
  12. ;     -1 if dest < src
  13. ;
  14.         .model  small
  15.         .code
  16.         public _ExtCmp
  17. _ExtCmp proc near
  18.  
  19.         push bp         ; save caller's stack frame
  20.         mov  bp,sp      ; address stack frame of this call
  21.         push si
  22.         push di
  23.  
  24.         mov  si,[bp+4]  ; source address
  25.         mov  di,[bp+6]  ; dest address
  26.  
  27.         mov  ax,[di+6]  ; compare high words first
  28.         sub  ax,[si+6]
  29.         jne  retrnval
  30.  
  31.         mov  ax,[di+4]
  32.         sub  ax,[si+4]
  33.         jne  retrnval
  34.  
  35.         mov  ax,[di+2]
  36.         sub  ax,[si+2]
  37.         jne  retrnval
  38.  
  39.         mov  ax,[di]
  40.         sub  ax,[si]
  41.         je   exithere   ; return 0 if equal
  42.  
  43. retrnval:
  44.         mov  ax,1
  45.         ja   exithere   ; flags unchanged since last cmp
  46.         mov  ax,-1
  47.  
  48. exithere:
  49.         pop  di
  50.         pop  si
  51.         pop  bp
  52.  
  53.         ret
  54.  
  55. _ExtCmp endp
  56.         end
  57.  
  58.